package com.yanqu.road.entity.activity.pasture;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 牧场点兵游戏数据
 */
public class PastureGameData {

    /**
     * 格子数据(从上往下,最后一个是最下面的行)
     */
    private List<List<PastureBlockData>> blockDataList;

    /**
     * 初始生成的格子数据(用于提前生成残局)
     */
    private List<List<PastureBlockData>> initBlockDataList;

    /**
     * 练习模式前几行需要先生成的
     */
    private List<List<PastureBlockData>> beforeGenBlockDataList;

    /**
     * 生成预览的格子数据
     */
    private List<List<PastureBlockData>> previewBlockDataList;

    /**
     * 当前积分
     */
    private long score;

    /**
     * 能量
     */
    private long energy;

    /**
     * 游戏状态
     */
    private int gameStatus;

    /**
     * 回合数
     */
    private int round;

    /**
     * 冻结回合数
     */
    private int freezeRound;

    /**
     * 本次操作后可生成n行
     */
    private int generateRow;

    /**
     * 本局使用充能号角的数量
     */
    private int useSkillItemCnt;

    /**
     * 本局使用了多少次技能
     */
    private int useSkillCnt;

    /**
     * 当前生成的模板回合(用于更新模板，回合数有变动时需要替换模板)
     */
    private int genRound;

    /**
     * 复活(返回上一步)次数
     */
    private int restartCnt;

    /**
     * 免费复活的次数
     */
    private int freeRestartCnt;

    /**
     * 本次基础分
     */
    @JSONField(serialize = false)
    private long baseScore;

    /**
     * 本回合消除的数量
     */
    @JSONField(serialize = false)
    private int chainClearCnt;

    /**
     * 本次消除过程(不入库)
     */
    @JSONField(serialize = false)
    private List<PastureMoveStepResult> moveStepResultList;

    /**
     * 消除掉落次数（加个控制防止死循环）
     */
    @JSONField(serialize = false)
    private int fallHandlerCnt;

    /**
     * 需要生成boss的格子表现
     */
    @JSONField(serialize = false)
    private List<PastureBlockData> needCreateBossDataList;

    /**
     * 已结算奖励
     */
    private String reward;

    /**
     * 已生成boss的回合
     */
    private List<Integer> genBossRoundList;


    // ---------------------这些字段用于日志------------------------------
    /**
     * 操作前积分
     */
    private long beforeScore;

    /**
     * 操作前能量值
     */
    private long beforeEnergy;

    /**
     * 本次激活的动物(使用技能时)
     */
    private int useSkillAnimalId;

    /**
     * 本局获得总能量数
     */
    private long totalGetEnergy;

    /**
     * 本局消耗总能量数
     */
    private long totalCostEnergy;

    /**
     * 本局使用的技能列表
     */
    private Map<Integer, Integer> useSkillTotalMap = new ConcurrentHashMap<>();

    /**
     * 本局消除方块列表
     */
    private Map<Integer,Integer> clearBlockTotalMap = new ConcurrentHashMap<>();

    /**
     * 本次消除方块列表(单次操作)
     */
    private Map<Integer,Integer> clearBlockOperateMap = new ConcurrentHashMap<>();
    // ---------------------这些字段用于日志------------------------------


    public PastureGameData() {
        blockDataList = new ArrayList<>();
        initBlockDataList = new ArrayList<>();
        beforeGenBlockDataList = new ArrayList<>();
        previewBlockDataList = new ArrayList<>();
        moveStepResultList = new ArrayList<>();
        needCreateBossDataList = new ArrayList<>();
        genBossRoundList = new ArrayList<>();
    }

    public List<List<PastureBlockData>> getBlockDataList() {
        return blockDataList;
    }

    public void setBlockDataList(List<List<PastureBlockData>> blockDataList) {
        this.blockDataList = blockDataList;
    }

    public List<List<PastureBlockData>> getPreviewBlockDataList() {
        return previewBlockDataList;
    }

    public void setPreviewBlockDataList(List<List<PastureBlockData>> previewBlockDataList) {
        this.previewBlockDataList = previewBlockDataList;
    }

    public List<List<PastureBlockData>> getInitBlockDataList() {
        return initBlockDataList;
    }

    public void setInitBlockDataList(List<List<PastureBlockData>> initBlockDataList) {
        this.initBlockDataList = initBlockDataList;
    }

    public List<List<PastureBlockData>> getBeforeGenBlockDataList() {
        return beforeGenBlockDataList;
    }

    public void setBeforeGenBlockDataList(List<List<PastureBlockData>> beforeGenBlockDataList) {
        this.beforeGenBlockDataList = beforeGenBlockDataList;
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        this.score = score;
    }

    public long getEnergy() {
        return energy;
    }

    public void setEnergy(long energy) {
        this.energy = energy;
    }

    public int getGameStatus() {
        return gameStatus;
    }

    public void setGameStatus(int gameStatus) {
        this.gameStatus = gameStatus;
    }

    public int getRound() {
        return round;
    }

    public void setRound(int round) {
        this.round = round;
    }

    public int getUseSkillItemCnt() {
        return useSkillItemCnt;
    }

    public void setUseSkillItemCnt(int useSkillItemCnt) {
        this.useSkillItemCnt = useSkillItemCnt;
    }

    public int getUseSkillCnt() {
        return useSkillCnt;
    }

    public void setUseSkillCnt(int useSkillCnt) {
        this.useSkillCnt = useSkillCnt;
    }

    public List<PastureMoveStepResult> getMoveStepResultList() {
        return moveStepResultList;
    }

    public void setMoveStepResultList(List<PastureMoveStepResult> moveStepResultList) {
        this.moveStepResultList = moveStepResultList;
    }

    public int getFreezeRound() {
        return freezeRound;
    }

    public void setFreezeRound(int freezeRound) {
        this.freezeRound = freezeRound;
    }

    public int getGenerateRow() {
        return generateRow;
    }

    public void setGenerateRow(int generateRow) {
        this.generateRow = generateRow;
    }

    public long getBaseScore() {
        return baseScore;
    }

    public void setBaseScore(long baseScore) {
        this.baseScore = baseScore;
    }

    public int getChainClearCnt() {
        return chainClearCnt;
    }

    public void setChainClearCnt(int chainClearCnt) {
        this.chainClearCnt = chainClearCnt;
    }

    public int getFallHandlerCnt() {
        return fallHandlerCnt;
    }

    public void setFallHandlerCnt(int fallHandlerCnt) {
        this.fallHandlerCnt = fallHandlerCnt;
    }

    public int getGenRound() {
        return genRound;
    }

    public void setGenRound(int genRound) {
        this.genRound = genRound;
    }

    public int getRestartCnt() {
        return restartCnt;
    }

    public void setRestartCnt(int restartCnt) {
        this.restartCnt = restartCnt;
    }

    public int getFreeRestartCnt() {
        return freeRestartCnt;
    }

    public void setFreeRestartCnt(int freeRestartCnt) {
        this.freeRestartCnt = freeRestartCnt;
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public long getBeforeScore() {
        return beforeScore;
    }

    public void setBeforeScore(long beforeScore) {
        this.beforeScore = beforeScore;
    }

    public long getBeforeEnergy() {
        return beforeEnergy;
    }

    public void setBeforeEnergy(long beforeEnergy) {
        this.beforeEnergy = beforeEnergy;
    }

    public int getUseSkillAnimalId() {
        return useSkillAnimalId;
    }

    public void setUseSkillAnimalId(int useSkillAnimalId) {
        this.useSkillAnimalId = useSkillAnimalId;
    }

    public long getTotalGetEnergy() {
        return totalGetEnergy;
    }

    public void setTotalGetEnergy(long totalGetEnergy) {
        this.totalGetEnergy = totalGetEnergy;
    }

    public long getTotalCostEnergy() {
        return totalCostEnergy;
    }

    public void setTotalCostEnergy(long totalCostEnergy) {
        this.totalCostEnergy = totalCostEnergy;
    }

    public Map<Integer, Integer> getUseSkillTotalMap() {
        return useSkillTotalMap;
    }

    public void setUseSkillTotalMap(Map<Integer, Integer> useSkillTotalMap) {
        this.useSkillTotalMap = useSkillTotalMap;
    }

    public Map<Integer, Integer> getClearBlockTotalMap() {
        return clearBlockTotalMap;
    }

    public void setClearBlockTotalMap(Map<Integer, Integer> clearBlockTotalMap) {
        this.clearBlockTotalMap = clearBlockTotalMap;
    }

    public Map<Integer, Integer> getClearBlockOperateMap() {
        return clearBlockOperateMap;
    }

    public void setClearBlockOperateMap(Map<Integer, Integer> clearBlockOperateMap) {
        this.clearBlockOperateMap = clearBlockOperateMap;
    }

    public List<PastureBlockData> getNeedCreateBossDataList() {
        return needCreateBossDataList;
    }

    public void setNeedCreateBossDataList(List<PastureBlockData> needCreateBossDataList) {
        this.needCreateBossDataList = needCreateBossDataList;
    }

    public List<Integer> getGenBossRoundList() {
        return genBossRoundList;
    }

    public void setGenBossRoundList(List<Integer> genBossRoundList) {
        this.genBossRoundList = genBossRoundList;
    }

    public PastureGameData clone(){
        PastureGameData gameData = new PastureGameData();

        List<List<PastureBlockData>> newBlockDataList = new ArrayList<>();
        for (List<PastureBlockData> pastureBlockData : blockDataList) {
            List<PastureBlockData> newBlockData = new ArrayList<>();
            for (PastureBlockData blockData : pastureBlockData) {
                newBlockData.add(blockData.clone());
            }
            newBlockDataList.add(newBlockData);
        }
        gameData.setBlockDataList(newBlockDataList);

        List<List<PastureBlockData>> newPreviewBlockDataList = new ArrayList<>();
        for (List<PastureBlockData> pastureBlockData : previewBlockDataList) {
            List<PastureBlockData> newPreviewBlockData = new ArrayList<>();
            for (PastureBlockData blockData : pastureBlockData) {
                newPreviewBlockData.add(blockData.clone());
            }
            newPreviewBlockDataList.add(newPreviewBlockData);
        }
        gameData.setPreviewBlockDataList(newPreviewBlockDataList);

        List<List<PastureBlockData>> newInitBlockDataList = new ArrayList<>();
        for (List<PastureBlockData> pastureBlockData : initBlockDataList) {
            List<PastureBlockData> newInitBlockData = new ArrayList<>();
            for (PastureBlockData blockData : pastureBlockData) {
                newInitBlockData.add(blockData.clone());
            }
            newInitBlockDataList.add(newInitBlockData);
        }
        gameData.setInitBlockDataList(newInitBlockDataList);

        gameData.setGameStatus(gameStatus);
        gameData.setEnergy(energy);
        gameData.setScore(score);
        gameData.setRound(round);
        gameData.setFreezeRound(freezeRound);
        gameData.setGenerateRow(generateRow);
        gameData.setUseSkillCnt(useSkillCnt);
        gameData.setUseSkillItemCnt(useSkillItemCnt);
        gameData.setGenRound(genRound);
        gameData.setReward(reward);
        gameData.setRestartCnt(restartCnt);
        gameData.setFreeRestartCnt(freeRestartCnt);
        gameData.setClearBlockOperateMap(clearBlockOperateMap);
        gameData.setUseSkillTotalMap(useSkillTotalMap);
        gameData.setTotalCostEnergy(totalCostEnergy);
        gameData.setTotalGetEnergy(totalGetEnergy);
        gameData.setGenBossRoundList(genBossRoundList);
        return gameData;
    }
}
